import java.util.ArrayList;
import java.util.Scanner;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;

public final class FuMaths {
	public static final void main (String args[]) {
		ArrayList<String> arr = new ArrayList<String>();
		for(String arg:args) {
			try {
				Scanner scan = new Scanner(new File(arg));
				while(scan.hasNextLine()) {
					String str = scan.nextLine();
					arr.add(str);
				}
			}
			catch (FileNotFoundException E) {
				System.out.println(E.toString());
			}
		}
		try {
			PrintWriter printer = new PrintWriter(new FileWriter("temp.math"));
			for(String i:arr) {
				printer.println(i);
			}
			printer.close();
		}
		catch (IOException E) {
			System.out.println(E.toString());
		}
		try {
			PrintWriter out = new PrintWriter(new FileWriter(args[0]+".math"));
			FuParser fup = new FuParser("temp.math");
			ArrayList<String> lines = fup.Lines();
			ArrayList<String> olines = fup.originalLines();
			FuCore fuc = new FuCore(lines);
			ArrayList<String> sols = fuc.Get();
			for(int i = 0;i < lines.size();i++) {
				out.printf("%s = %s\n",olines.get(i),sols.get(i));
			}
			out.close();
		}
		catch (IOException E) {
			System.out.println(E.toString());
		}
		try {
			File f = new File("temp.math");
			boolean succes = f.delete();
			if(!succes) {
				throw new IOException();
			}
		}
		catch (IOException E) {
			System.out.println(E.toString());
		}
	}
}

